Skip to content

fix: escape and mask the SA password - #348

Merged
dhensby merged 4 commits into
tediousjs:masterfrom
dhensby:fix/sa-password-quoting
Nov 21, 2026
Merged

dhensby merged 4 commits into
tediousjs:masterfrom
dhensby:fix/sa-password-quoting

Conversation

@dhensby

@dhensby dhensby commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

The action runs SQL Server setup with windowsVerbatimArguments, so @actions/exec adds no quoting, and it wrapped the password as /SAPWD="${password}" without escaping. A double quote in sa-password, or a backslash at the end of it, changed how setup split its command line. Setup then lost the licence switch and the later arguments, or set a different password from the one in the sa-password output. The password was also never masked, so the setup command line and every sqlcmd readiness attempt printed it in clear when it didn't come from a secret.

  • Escaping. A new quoteWindowsArgument() quotes a value with the standard Windows quoting rules: it escapes each double quote, and doubles only the backslashes that come before a double quote or the closing quote. The action uses it for the values it adds itself: /SAPWD, /SQLCOLLATION and /UpdateSource. Plain values give the same command line as before. The user's install-arguments are still passed as given. A unit test splits the command line the way the Windows C runtime does, and checks that every string of up to four characters from a " \ space tab % ^ ! comes back unchanged, with the later switches intact.
  • Masking. gatherInputs() registers the password with core.setSecret, and also its escaped form, which is what the command lines show when the password needs escaping. This includes the public default password. GitHub leaves out job outputs that contain a masked value, so a workflow that passes sa-password on as a job output loses it. Step outputs still work. The README says this, and also that GitHub still prints the inputs in the step header before the action starts.
  • Double quotes are rejected. SQL Server setup passes its arguments on to the installer that it starts, and a value with a double quote doesn't survive that, even when it is escaped. On a throwaway experiment branch in my fork, a password with a double quote made setup fail on both 2022 and 2025 when the outer setup started its inner installer, with a misleading error that Detail.txt was in use by another process. Passwords with spaces, % ^ ! and backslashes, including a trailing one, passed. The action now fails at the start, before anything is downloaded, when sa-password or db-collation contains a double quote, with an error that names the input but not the value. The sa-password input description says so.
  • CI. A new runaction job installs SQL Server 2025 with the password Str0ng Pa ss%^!\, which contains a space, characters that cmd.exe treats specially and a trailing backslash. The check step from ci: check that the installed instance works in runaction #344 logs in over TCP with the sa-password output, so the job passes only if setup set exactly that password. 2025 exits with 3010 in CI, so the action's own readiness check must also log in with it.

Closes #324

🤖 Generated with Claude Code

dhensby and others added 4 commits November 21, 2026 09:58
The action runs SQL Server setup with windowsVerbatimArguments, where
@actions/exec adds no quoting, and it wrapped the password as
`/SAPWD="${password}"` without escaping. A double quote in the
password, or a backslash at the end of it, therefore changed how setup
split its command line. Setup then lost the licence switch and every
later argument, or set a different password from the one in the
sa-password output, so later logins failed.

Quote the values that the action adds to the command line itself
(/SAPWD, /SQLCOLLATION and /UpdateSource) with the standard Windows
quoting rules, which escape each double quote and double the
backslashes that come before a double quote or the closing quote.
Plain values give the same command line as before. The user's
install-arguments are still passed as they are given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The action never registered the password as a secret. @actions/exec
prints each command line before it runs it, so the setup command line
and every sqlcmd readiness attempt showed the password in clear when it
didn't come from a secret, and so did later steps that printed it.

Register the password with core.setSecret before anything can log it,
and also its escaped form, which is what the command lines show when
the password needs escaping. The README now says what masking covers:
GitHub still shows the input in the step header before the action
starts, and it leaves out job outputs that contain a masked value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a runaction job that installs SQL Server 2025 with an SA password
that contains a space, characters that cmd.exe treats specially and a
trailing backslash. The check step logs in over TCP with the
sa-password output, so the job passes only if setup set exactly that
password. 2025 exits with 3010 in CI, so the action's own readiness
check must also log in with it. The other jobs keep the action's
default password.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SQL Server setup passes its arguments on to the installer that it
starts, and a value with a double quote doesn't survive that, even
when it is escaped. In CI, a password with a double quote made setup
fail on both SQL Server 2022 and 2025 when the outer setup started its
inner installer, with a misleading error that Detail.txt was in use by
another process. Passwords with spaces, symbols and backslashes,
including a trailing one, passed.

Fail at the start, before anything is downloaded, when sa-password or
db-collation contains a double quote, with an error that names the
input but not the value. The password is masked before the check. The
sa-password input description says that a double quote isn't allowed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhensby
dhensby force-pushed the fix/sa-password-quoting branch from 7ba3b2d to 0b08c57 Compare November 21, 2026 10:00
@dhensby
dhensby marked this pull request as ready for review November 21, 2026 10:01
@dhensby
dhensby merged commit 0eb81d4 into tediousjs:master Nov 21, 2026
24 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 4.1.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sa-password values with a double quote or a trailing backslash break the setup command line

1 participant